From: Barnabás Pőcze Date: Wed, 3 Jan 2024 02:04:46 +0000 (+0100) Subject: status/backlight: Fix keyboard backlight infinite loop X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~281^2~2^2~138 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=be944ff2dcc2bbe25152c0736c20d8045a5581e9;p=gnome-shell.git status/backlight: Fix keyboard backlight infinite loop The logic could enter an infinite loop because it tried to propagate local changes to g-s-d that were caused by signals sent by g-s-d. For example: 1. slider is set to 50 2. Set(50) dbus call is sent 3. slider is set to 51 4. Set(51) dbus call is sent 5. PropertiesChanged arrives due to Set(50) 6. this._sliderItem.value is set to 50 7. notify::value is emitted from this._sliderItem 8. Set(50) dbus call is sent 9. PropertiesChanged arrives due to Set(51) 10. this._sliderItem.value is set to 51 11. notify::value is emitted from this._sliderItem 12. Set(51) dbus call is sent To alleviate this issue, block signal handlers when the local state is changed due to a remote event. Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7111 Part-of: --- diff --git a/js/ui/status/backlight.js b/js/ui/status/backlight.js index f35791848..ca901d547 100644 --- a/js/ui/status/backlight.js +++ b/js/ui/status/backlight.js @@ -177,10 +177,10 @@ class KeyboardBrightnessToggle extends QuickMenuToggle { this._discreteItem, 'value', GObject.BindingFlags.SYNC_CREATE); - this._sliderItem.connect('notify::value', + this._sliderItemChangedId = this._sliderItem.connect('notify::value', () => (this._proxy.Brightness = this._sliderItem.value)); - this._discreteItem.connect('notify::value', + this._discreteItemChangedId = this._discreteItem.connect('notify::value', () => (this._proxy.Brightness = this._discreteItem.value)); } @@ -194,6 +194,9 @@ class KeyboardBrightnessToggle extends QuickMenuToggle { this.checked = brightness > 0; const useSlider = this._proxy.Steps >= 4; + this._sliderItem.block_signal_handler(this._sliderItemChangedId); + this._discreteItem.block_signal_handler(this._discreteItemChangedId); + this._sliderItem.set({ visible: useSlider, value: brightness, @@ -201,6 +204,9 @@ class KeyboardBrightnessToggle extends QuickMenuToggle { if (!useSlider) this._discreteItem.nLevels = this._proxy.Steps; + + this._sliderItem.unblock_signal_handler(this._sliderItemChangedId); + this._discreteItem.unblock_signal_handler(this._discreteItemChangedId); } });